<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/2/17 0017
 * Time: 16:54
 */

namespace app\admin\controller;


use app\Lib\Model\Login\DoLogin;
use think\captcha\Captcha;
use think\Controller;
use think\Url;

class UserLogin extends Controller
{
    public function login(){
        $login = new DoLogin();
        if($login->isLogin()){
            $this->success('你已经在登录中',Url::build('admin/index/index'));
        };
        return $this->fetch();
    }

    public function doLogin(){
        try{
            $post = input('post.');
            $login = new DoLogin();
            $login->setAccount($post['account']);
            $login->setPassword($post['password']);
            $login->run();
            return ['code'=>1,'msg'=>'登录成功','url'=>Url::build('admin/index/index')];
        }catch (\Exception $e){
            return ['code'=>-1,'msg'=>$e->getMessage()];
        }
    }
}